package com.hfzy.ihk.web.userCenter.mapper;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hfzy.ihk.facade.userCenter.entity.UserInfo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 用于集成spring security Mapper 接口
 * </p>
 *
 * @author wws
 * @since 2018-12-28
 */
public interface UserMapper extends BaseMapper<UserInfo> {

    @Select("select * from user_info u where u.username=#{username}")
    UserInfo findUserByUserName(String username);


    Integer count(@Param("params") Map<String, Object> params);



    List<UserInfo> list(@Param("params") Map<String, Object> params, @Param("offset") Integer offset,
                       @Param("limit") Integer limit);

    UserInfo queryUserInfo(@Param("userId")Long userId);


    @Update("update user_info set enabled=#{enabled} where id = #{id}")
    int updateEnabledById(@Param("id")Long id,@Param("enabled")String enabled );

    @Update("update user_info t set t.password = #{password} where t.id = #{id}")
    int changePassword(@Param("id") Long id, @Param("password") String password);



    @Select("select web_server_redirect_uri as webServerRedirectUri from oauth_client_details where client_id=#{userName}")
    List<String> queryLogoutUrlByclientId(String clientId);


    @Select("select uhr.user_id from user_has_role  uhr inner join user_info ui on ui.id = uhr.user_id where ui.enabled=true and uhr.role_id=#{roleId} ")
    List<Integer> selectUserIdsByRoleId(int roleId);


    List<UserInfo> querySimpleUserInfo(@Param("userIds")List<Integer> userIds);
}
